/**
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
"use strict";
define(["ojs/ojcore","jquery","promise"],function(a,g){a.$={};o_("AnimationUtils",a.$,a);a.$.ry=function(b,c,d,e,f,h){var k=g(b),l=[].concat(f);return(new Promise(function(b){function g(){s||(k.off("transitionend webkitTransitionEnd",t),b(!0),s=!0)}function t(a){a=l.indexOf(a.originalEvent.propertyName);-1<a&&(1<l.length?l.splice(a,1):g())}var s=!1;null==d.css&&(d.css={});d.css.transition=a.$.Asa(f,e);var q=a.$.hDa(k,c,d,e,h||f);a.$.r4(k,c,1<q);k.on("transitionend webkitTransitionEnd",t);window.setTimeout(function(){a.$.r4(k,
d,1<q);setTimeout(g,a.$.P4(k)+100)},20)})).then(function(){c&&c.addClass&&k.removeClass(c.addClass);d&&d.addClass&&k.removeClass(d.addClass);a.$.cDa(k)})};a.$.Eca=function(b,c,d,e){for(var f in c)if(c=a.$.w7(f),!(d.hasOwnProperty(c)||e&&-1!=e.indexOf(c))){var g=b[0].style;d[c]=void 0===g[c]?g[a.$.l9(c)]:g[c]}};a.$.hDa=function(b,c,d,e,f){var g=b.data("_ojSavedStyle")||{};c=c&&c.css?c.css:{};d=d&&d.css?d.css:{};e&&"all"===e.persist||(f=null);a.$.Eca(b,c,g,f);a.$.Eca(b,d,g,f);b.data("_ojSavedStyle",
g);e=b.data("_ojEffectCount")||0;b.data("_ojEffectCount",++e);return e};a.$.cDa=function(a){var c=a.data("_ojEffectCount");if(1<c)a.data("_ojEffectCount",c-1);else if(c=a.data("_ojSavedStyle"))a.css(c),a.removeData("_ojSavedStyle"),a.removeData("_ojEffectCount")};a.$.w7=function(a){if(0<=a.indexOf("-")){var c="";a=a.split("-");for(var d=0;d<a.length;d++){var e=a[d];e&&(c=c?c+(e.charAt(0).toUpperCase()+e.slice(1)):e)}return c}return a};a.$.cva=function(a){return a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()};
a.$.l9=function(a){return"webkit"+a.charAt(0).toUpperCase()+a.slice(1)};a.$.C5=function(b,c,d,e,f){c.css[d]&&(d=a.$.w7(d),(b=b[0].style[d]||b[0].style[a.$.l9(d)])&&0!=b.indexOf(e)&&(c.css[d]=b+f+c.css[d]))};a.$.r4=function(b,c,d){c&&(c.css&&(d&&(a.$.C5(b,c,"transform","none"," "),a.$.C5(b,c,"transition","all",", ")),b.css(c.css)),c.addClass&&b.addClass(c.addClass),c.removeClass&&b.removeClass(c.removeClass))};a.$.O4=function(a,c,d){c=a.css(c);var e=a.css(d+"Delay");d=a.css(d+"Duration");a=e.split(",");
d=d.split(",");c=c.split(",").length;for(var e=a.length,f=d.length,g=0,k=0;k<c;k++){var l=d[k%f],l=-1<l.indexOf("ms")?parseFloat(l):1E3*parseFloat(l);if(0<l)var m=a[k%e],m=-1<m.indexOf("ms")?parseFloat(m):1E3*parseFloat(m),g=Math.max(g,m+l)}return g};a.$.P4=function(b){var c=a.$.O4(b,"animationName","animation");b=a.$.O4(b,"transitionProperty","transition");return Math.max(c,b)};a.$.Sta=function(a,c){a.delay=a.delay||c.delay;a.duration=a.duration||c.duration;a.timingFunction=a.timingFunction||c.timingFunction;
a.persist=a.persist||c.persist};a.$.ym=function(b,c,d){return new Promise(function(e){function f(){s=!0;k()}function h(){t=!0;k()}function k(){t&&s&&(l.removeClass(m),l.removeClass(r),e(!0),l.trigger("ojanimateend",{action:c}))}var l=g(b),m="oj-animate-"+c,r=m+"-active",t=!1,s=!1,q=g.Event("ojanimatestart");l.trigger(q,{action:c,endCallback:h});if(!q.isDefaultPrevented()){for(var q=[].concat(d),p=[],n={},u=0;u<q.length;u++){var v=q[u],w="",y;null!=v&&"none"!=v&&("string"==typeof v?(w=v,y={}):"object"==
typeof v&&(w=v.effect,y=g.extend({},v)),a.$.Sta(y,n),n=g.extend({},y));w&&a.$[w]&&p.push(a.$[w](b,y))}p.length?Promise.all(p).then(h):h()}l.addClass(m);window.setTimeout(function(){l.addClass(r);setTimeout(f,a.$.P4(l)+100)},20)})};o_("AnimationUtils.startAnimation",a.$.ym,a);a.$.tz=function(b,c){null==a.$.Ey&&(a.$.Ey=a.Wc.De("oj-animation-effect-default-options"));return g.extend({duration:"400ms"},a.$.Ey?a.$.Ey[b]:null,c)};a.$.Asa=function(b,c){var d="";if(b)for(var e=0;e<b.length;e++){var f=a.$.cva(b[e]),
d=d+((0<e?", ":"")+f+" "+c.duration);c.timingFunction&&(d+=" "+c.timingFunction);c.delay&&(d+=" "+c.delay)}return d};a.$.S6=function(b,c,d,e,f){c=a.$.tz(d,c);d={css:{opacity:e}};f={css:{opacity:f}};c&&(c.startOpacity&&(d.css.opacity=c.startOpacity),c.endOpacity&&(f.css.opacity=c.endOpacity));return a.$.ry(b,d,f,c,["opacity"])};a.$.fadeIn=function(b,c){return a.$.S6(b,c,"fadeIn",0,1)};o_("AnimationUtils.fadeIn",a.$.fadeIn,a);a.$.fadeOut=function(b,c){return a.$.S6(b,c,"fadeOut",1,0)};o_("AnimationUtils.fadeOut",
a.$.fadeOut,a);a.$.expand=function(b,c){return a.$.P6(b,c,!0)};o_("AnimationUtils.expand",a.$.expand,a);a.$.collapse=function(b,c){return a.$.P6(b,c,!1)};o_("AnimationUtils.collapse",a.$.collapse,a);a.$.P6=function(b,c,d){c=a.$.tz(d?"expand":"collapse",c);var e={},f={},h=c.direction||"height";b=g(b);var k=b.width(),l=b.height(),m=b.css("maxWidth"),r=b.css("maxHeight"),t=e.css={},s=f.css={};"none"!==m&&(k=m);"none"!==r&&(l=r);m=[];if("both"===h||"height"===h)t.maxHeight=d?0:l,s.maxHeight=d?l:0,m.push("maxHeight");
if("both"===h||"width"===h)t.maxWidth=d?0:k,s.maxWidth=d?k:0,m.push("maxWidth");return a.$.ry(b[0],e,f,c,m)};a.$.X_=function(b,c){return a.$.Mea(b,c,!0)};o_("AnimationUtils.zoomIn",a.$.X_,a);a.$.Y_=function(b,c){return a.$.Mea(b,c,!1)};o_("AnimationUtils.zoomOut",a.$.Y_,a);a.$.Mea=function(b,c,d){c=a.$.tz(d?"zoomIn":"zoomOut",c);var e={},f={},h=c.axis||"both";b=g(b);var h="both"===h?"scale":"x"===h?"scaleX":"scaleY",k=e.css={},l=f.css={};k.transform=h+"("+(d?0:1)+") translateZ(0)";l.transform=h+"("+
(d?1:0)+") translateZ(0)";k.transformOrigin=c.transformOrigin||"center";return a.$.ry(b[0],e,f,c,["transform"])};a.$.HLa=function(b,c){return a.$.ep(b,c,!0)};o_("AnimationUtils.slideIn",a.$.HLa,a);a.$.ILa=function(b,c){return a.$.ep(b,c,!1)};o_("AnimationUtils.slideOut",a.$.ILa,a);a.$.ep=function(b,c,d){c=a.$.tz(d?"slideIn":"slideOut",c);var e={},f={},h=c.direction||"start";b=g(b);var k="0",l="0",m=e.css={},r=f.css={};if(c.offsetX||c.offsetY)c.offsetX&&(k=c.offsetX),c.offsetY&&(l=c.offsetY);else{var t=
b.outerWidth(),s=b.outerHeight(),q="rtl"===a.D.In();switch(h){case "left":k=(d?t:-t)+"px";break;case "right":k=(d?-t:t)+"px";break;case "top":l=(d?s:-s)+"px";break;case "bottom":l=(d?-s:s)+"px";break;case "end":k=(d?-t:t)*(q?-1:1)+"px";break;default:k=(d?t:-t)*(q?-1:1)+"px"}}d?(m.transform="translate("+k+","+l+") translateZ(0)",r.transform="translate(0,0) translateZ(0)"):(m.transform="translate(0,0) translateZ(0)",r.transform="translate("+k+","+l+") translateZ(0)");return a.$.ry(b[0],e,f,c,["transform"])};
a.$.nLa=function(b,c){c=a.$.tz("ripple",c);var d={},e={},f=g(b),h=f.outerWidth(),k=f.outerHeight(),l=g("\x3cdiv style\x3d'position:absolute; overflow:hidden'\x3e"),m=g("\x3cdiv class\x3d'oj-animation-effect-ripple oj-animation-rippler'\x3e"),r="static"==f.css("position")?f.position():{left:0,top:0};f.prepend(l);l.css({left:r.left+"px",top:r.top+"px",width:h+"px",height:k+"px"});l.prepend(m);f=d.css={};h=e.css={};a.$.gEa(f,m,l,c);f.transform="scale(0) translateZ(0)";f.opacity=c.startOpacity||m.css("opacity");
h.transform="scale(1) translateZ(0)";h.opacity=c.endOpacity||0;c.persist="all";return a.$.ry(m[0],d,e,c,["transform","opacity"]).then(function(){l.remove()})};o_("AnimationUtils.ripple",a.$.nLa,a);a.$.gEa=function(b,c,d,e){c=c.width();var f=d.width(),g=d.height();if(e.diameter){var k=e.diameter,l=parseInt(k,10);isNaN(l)||(c="%"==k.charAt(k.length-1)?Math.floor(Math.min(f,g)*(l/100)):l,b.width=c+"px",b.height=c+"px")}d="static"==d.css("position")?d.position():{left:0,top:0};f=a.$.U4(e.offsetX,c,f,
d.left);null!=f&&(b.left=f+"px");f=a.$.U4(e.offsetY,c,g,d.top);null!=f&&(b.top=f+"px");e.color&&(b.backgroundColor=e.color)};a.$.U4=function(a,c,d,e){var f;a=a||"50%";var g=parseInt(a,10);isNaN(g)||(f="%"==a.charAt(a.length-1)?g/100*d-c/2:g-c/2,f=Math.floor(f+e));return f};a.$.tNa=function(b,c){c=c||{};var d={fadeOut:1,collapse:1,zoomOut:1,slideOut:1},e=c.removeEffect||"fadeOut",f=g(".oj-animation-rippler",b);if(0===f.length)console.warn("No rippler so returning");else return e in d?a.$[e](f,c).then(function(){f.remove()}):
f.remove()};a.$.k7=function(b,c,d,e,f){c=a.$.tz(d,c);d={};var g={},k={css:d},l={css:g},m="rotateY(",r="2000px",t="hidden",s="center";c&&("x"===c.axis&&(m="rotateX("),c.startAngle&&(e=c.startAngle),c.endAngle&&(f=c.endAngle),c.perspective&&(r=c.perspective),c.backfaceVisibility&&(t=c.backfaceVisibility),c.transformOrigin&&(s=c.transformOrigin));m="perspective("+r+") "+m;d.transform=m+e+")";d.backfaceVisibility=t;d.transformOrigin=s;g.transform=m+f+")";return a.$.ry(b,k,l,c,["transform"],["transform",
"backfaceVisibility","transformOrigin"])};a.$.HHa=function(b,c){return a.$.k7(b,c,"flipIn","-180deg","0deg")};o_("AnimationUtils.flipIn",a.$.HHa,a);a.$.IHa=function(b,c){return a.$.k7(b,c,"flipOut","0deg","180deg")};o_("AnimationUtils.flipOut",a.$.IHa,a)});